package com.example.fresheveryday.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.fresheveryday.po.Blog;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper extends BaseMapper<Blog> {
  @Select("select * from" + " blog  " )
  IPage<Blog> getAllBlog(IPage<Blog> page);

  @Select("select * from blog limit 3")
  List<Blog> getThree();
  //动态查询
  @Select("select * from" + " blog ${ew.customSqlSegment} " )
  IPage<Blog> getBlogByConditions(IPage<Blog> page, @Param("ew") Wrapper wrapper);
  //分页计数
  @Select("select count(user_id) from blog ${ew.customSqlSegment}")
  int countByConditions(@Param("ew") Wrapper wrapper);

  @Select("select * from blog limit 6")
  List<Blog> getSix();

}
